/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package alcatelparser.tags;

import alcatelparser.modules.AlgoUtil;
import alcatelparser.modules.BuilderFactory;
import alcatelparser.modules.I;

/**
 *
 * @author geniuz
 */
public class RecordExtensionsTag extends DefaultParserTag
{

    public RecordExtensionsTag()
    {
        value = "";
    }
    private String value;
    public String GetResult(){
        return value;
    }
    public final void parseTag(int ai[], int i)
    {
        value = "";
        _array = ai;
        _startParsePosition = i;
        int j = AlgoUtil.getLength(ai, i + 1);
        setStandartLength(ai, i);
        if(isFullForm())
            BuilderFactory.getBuilder().writeTagContent(3, 0, getTagPropertiesValue(I.I(5983)), getTagIdentifyContent(i, i + 1));
        int i1;
        for(int k = 2; k < j; k += i1)
        {
            int l = _array[i + 2];
            i1 = AlgoUtil.getLength(_array, i + 3);
            if(isFullForm())
                BuilderFactory.getBuilder().writeTagContent(4, 0, getTagPropertiesValue(I.I(6005)), getTagIdentifyContent(i + 2, i + 3));
            parseInnerTag(i + 4, i1);
        }

    }

    private void parseInnerTag(int i, int j)
    {
        int j1;
        for(int k = 0; k < j; k += j1 + 2)
        {
            int l = k + i;
            int i1 = AlgoUtil.getLength(_array, l);
            j1 = AlgoUtil.getLength(_array, l + 1);
            int k1 = calculateInnerTagType(i1);
            switch(k1)
            {
            case 0: // '\0'
                parseCDE(l);
                break;

            case 2: // '\002'
                parseTariffCode(l);
                break;

            case 4: // '\004'
                parseBCG(l);
                break;

            case 5: // '\005'
                parseAdditionalIN(l);
                break;
            }
        }

    }

    private void parseTariffCode(int i)
    {
        TariffCodeTag tariffcodetag = new TariffCodeTag();
        int j = AlgoUtil.getLength(_array, i + 1);
        String p1 = getStringContent(i + 2, j);
        value += p1 + "~";
        tariffcodetag.parseTag(_array, i);
    }

    private void parseAdditionalIN(int i)
    {
        AdditionalINTag additionalintag = new AdditionalINTag();
        additionalintag.parseTag(_array, i);
    }

    private void parseBCG(int i)
    {
        BCGTag bcgtag = new BCGTag();
        bcgtag.parseTag(_array, i);
    }

    private void parseCDE(int i)
    {
        CDETag cdetag = new CDETag();
        int x = i + 2;
        int mmm = _array[x + 2];
        value += mmm + "~";
        cdetag.parseTag(_array, i);
    }

    public final String getParseIdentityTag()
    {
        return I.I(5496);
    }
}
